package com.leapp.sk.sever.classs

import android.content.Context
import com.example.mvp.bean.ClassMemberInfoEntity
import com.example.util.ObjectProcessingUtil
import com.leapp.sk.bean.ClassDetialDataEntity
import com.leapp.sk.bean.ParentListEntity
import com.leapp.sk.bean.TeacherListEntity
import com.leapp.sk.bean.response.classs.ClassDetialResponseEntity
import com.leapp.sk.viewdelegate.classs.ClassDetialDelegate

/**
 * 班级详情
 * @author  chaohaipeng  on 2018/8/20.
 */
class ClassDetialSever {
    private object mHolder {
        val instance = ClassDetialSever()
    }
    companion object {
        fun getInstance(): ClassDetialSever {
            return mHolder.instance
        }
    }

    /**
     * 绑定数据
     */
    fun binderData(context: Context, viewDelegate: ClassDetialDelegate, obj: ClassDetialResponseEntity?){
        val teacherData = ClassDetialSever.getInstance().getTeacherData(obj)
        viewDelegate?.initTechere(context,teacherData)
        val parentData = ClassDetialSever.getInstance().getParentData(obj)
        val classDetialData = ClassDetialSever.getInstance().getClassDetialData(obj)
        viewDelegate?.initClassMember(context,parentData,classDetialData?.total)
        viewDelegate?.setclassNameContent(classDetialData?.className)
        viewDelegate?.setNickContent(classDetialData?.nickName)
        viewDelegate?.setClassID(classDetialData?.classId)
        if (classDetialData?.noDisturb==1){
            viewDelegate?.setPushbtn(false)
        }else{
            viewDelegate?.setPushbtn(true)
        }


      }


    /**
     * 获取老师数据
     */
   private fun getTeacherData(obj: ClassDetialResponseEntity?):List<ClassMemberInfoEntity>?{
        val classDetialDataEntity:ClassDetialDataEntity= ObjectProcessingUtil.objMandatoryConversionClass(obj?.data, ClassDetialDataEntity::class.java)
        val teacherList = classDetialDataEntity?.teacherList
        return teacherList
    }
    /**
     * 获取老师数据
     */
    private  fun getParentData(obj: ClassDetialResponseEntity?):List<ClassMemberInfoEntity>?{
        val classDetialDataEntity:ClassDetialDataEntity= ObjectProcessingUtil.objMandatoryConversionClass(obj?.data, ClassDetialDataEntity::class.java)
        val parentList = classDetialDataEntity?.parentList
        return parentList
    }

    /**
     * 获取班级数据
     */
    private  fun getClassDetialData(obj: ClassDetialResponseEntity?):ClassDetialDataEntity?{
        val classDetialDataEntity:ClassDetialDataEntity= ObjectProcessingUtil.objMandatoryConversionClass(obj?.data, ClassDetialDataEntity::class.java)
        return classDetialDataEntity
    }


    /**
     * 获取班级和宝贝关系ID
     */
      fun getClassPersonnelId(obj: ClassDetialResponseEntity?):String?{
        val classDetialDataEntity:ClassDetialDataEntity= ObjectProcessingUtil.objMandatoryConversionClass(obj?.data, ClassDetialDataEntity::class.java)
        return classDetialDataEntity.classPersonnelId
    }
}